﻿#include "qtwh.h"
#include "ui_qtwh.h"
extern QString txtype;
qtwh::qtwh(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::qtwh)
{
    ui->setupUi(this);
    this->setAttribute(Qt::WA_QuitOnClose, false);
#ifdef Q_OS_ANDROID
    int fontId = QFontDatabase::addApplicationFont(":/FontStyle/AlibabaPuHuiTi-3-55-Regular.ttf");
    if (fontId != -1) {
        QStringList fontFamilies = QFontDatabase::applicationFontFamilies(fontId);
        if (!fontFamilies.isEmpty()) {
            QString familyName = fontFamilies.first();
            QFont font(familyName, 18); // 创建一个QFont对象，设置字体名称和默认大小

            // 使用setFont方法设置字体，传入QFont对象
            ui->label->setFont(font);
            ui->wk_rb->setFont(font);
            ui->label_2->setFont(font);
            ui->ip_le->setFont(font);
            ui->label_3->setFont(font);
            ui->port_le->setFont(font);
            ui->qx_bt->setFont(font);
            ui->qd_bt->setFont(font);
            ui->sbo_bt->setFont(font);
            ui->sbc_bt->setFont(font);
            ui->fso_bt->setFont(font);
            ui->fsc_bt->setFont(font);
            ui->qx_bt_2->setFont(font);
        }
    }
#endif
}

qtwh::~qtwh()
{
    delete ui;
}
// 网络通信 cnr
void qtwh::on_wk_rb_clicked(bool checked)
{
    if(checked){
        txtype="0";
    }
}
// usb通信 cnr
void qtwh::on_ck_rb_clicked(bool checked)
{
    if(checked){
        txtype="1";
    }
}

void qtwh::on_qx_bt_clicked()
{
    this->close();
}

void qtwh::on_qx_bt_2_clicked()
{
    this->close();
}

void qtwh::on_sbo_bt_clicked()
{
    if(shui==0){
        ui->sbo_bt->setStyleSheet("background: #F5F5F5;color: #BFBFBF;border-radius: 4px;border: 1px solid #D9D9D9;");
        ui->sbc_bt->setStyleSheet("background: #2F42CD;border-radius: 4px;color: rgb(255, 255, 255);");
        shui=1;
    }
}

void qtwh::on_sbc_bt_clicked()
{
    if(shui==1){
        ui->sbc_bt->setStyleSheet("background: #F5F5F5;color: #BFBFBF;border-radius: 4px;border: 1px solid #D9D9D9;");
        ui->sbo_bt->setStyleSheet("background: #2F42CD;border-radius: 4px;color: rgb(255, 255, 255);");
        shui=0;
    }
}

void qtwh::on_fso_bt_clicked()
{
    if(feng==0){
        ui->fso_bt->setStyleSheet("background: #F5F5F5;color: #BFBFBF;border-radius: 4px;border: 1px solid #D9D9D9;");
        ui->fsc_bt->setStyleSheet("background: #2F42CD;border-radius: 4px;color: rgb(255, 255, 255);");
        feng=1;
    }
}

void qtwh::on_fsc_bt_clicked()
{
    if(feng==1){
        ui->fsc_bt->setStyleSheet("background: #F5F5F5;color: #BFBFBF;border-radius: 4px;border: 1px solid #D9D9D9;");
        ui->fso_bt->setStyleSheet("background: #2F42CD;border-radius: 4px;color: rgb(255, 255, 255);");
        feng=0;
    }
}
